<?php

class Ajax extends Controller {

	public $cont;
	public $page = "ajax";
	
	public function __construct(){
		parent::Controller();
		
	    
	}
	
	public function index(){
		redirect($this->config->item("base_url"));
		return false;
	}
	
	
	
    public function change_language(){
        //Get the new language by post and pass it to the XSS filter
        $new_language = $this->input->post("new_language", TRUE);
        
        //Set the new language here and send the status to the view
        //Do some cookies or SOMETHING in here...
        $this->session->unset_userdata("language");
        $this->session->set_userdata("language", $new_language);
        $language_in_use = $this->session->userdata("language");
        
        if($language_in_use){
            $out = "true";
        }else{
            $out = "false";
        }
        $output = array("new_language"=>$language_in_use , "status"=>$out);
        echo json_encode($output);
    }
	
}
?>

